<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Artisan;
//控制器创建: php artisan make:controller Admin/IndexController

class IndexController extends CommonController
{
    /**
     * 首页
     */
    public function index()
    {
        $adminid = request()->user()->id;
        $where['menustatus'] = 1;
        $where[] = ['levels', '<', 3];
        $query = DB::table('auth_rule');
        $query->where($where);
        if($adminid != 1){
            $query -> whereIn('id',$this->adminRules);
        }
        $wheres['id'] =$this->adminRules;
        $authRule = $query->orderByRaw('sort asc,title desc')->get();
        $authRule = json_decode(json_encode($authRule),true);
        $data['menu'] = getTree($authRule);
        //系统信息
      /*  $version = DB::select('select version() as ver');
        $config = [
            'url'             => $_SERVER['HTTP_HOST'],
            'document_root'   => $_SERVER['DOCUMENT_ROOT'],
            'server_os'       => PHP_OS,
            'server_port'     => $_SERVER['SERVER_PORT'],
            'server_ip'       => $_SERVER['SERVER_ADDR'],
            'server_soft'     => $_SERVER['SERVER_SOFTWARE'],
            'php_version'     => PHP_VERSION,
            'mysql_version'   => $version[0]->ver,
        ];
        return view('admin.index.index')->with('config',$config);*/
        return view('admin/index/index')->with('data',$data);
    }

    //清除缓存
    /*清理视图缓存
    php atisan view:clear
    清除运行缓存
    php artisan cache:clear
    清除配置
    php artisan  config:clear
    清除路由缓存
    php artisan route:clear
    创建建立session表迁移
    php artisan session:table*/
    public function clear()
    {
        Artisan::call('view:clear');
 /*       Artisan::call('cache:clear');
        Artisan::call('route:clear');*/
        return response()->json(['code'=>1,'msg'=>'清除缓存成功']);
    }


}
